約 4,447,612 件
https://w.atwiki.jp/rubyist-kyushu/pages/14.html
第二回Rails初心者講習会のご案内 九州におけるRubyユーザーグループ「Rubyist九州」では、 話題のWebフレームワークRuby on Railsの初心者向け講習会を開催しております。 前回ご好評を頂き、会場満席のため参加できない方が多数おられましたので、急遽、第二回の開催を決定いたしました。 Ruby on Railsは、強力なプログラミング言語 Rubyを利用して、 効率的にWebアプリケーションの開発を行うフレームワークです。 2005年より爆発的な人気を博しているのは、皆様もご存知かと思います。 このRails初心者講習会は、九州でRailsを学ぶことができる貴重な機会となります。 またユーザーグループによる開催ですので、参加費用も極めてお得になっています。 テキストとしては、書籍 (RailsによるアジャイルWebアプリケーション開発) を 利用しますのでご持参ください。Rails作者が執筆している、定評あるテキストです。 参加申し込みは下記までお願いします。 この素晴らしい機会に、皆様や貴社人材のスキルアップを図りませんか? 開催概要 主催 Rubyist九州、AIP (特定非営利活動法人 高度IT人材アカデミー) 後援 サン・マイクロシステムズ株式会社 協賛 社団法人 情報処理学会 九州支部 会場 姪浜 AIP講義室 ( http //www.npo-aip.or.jp/about/map.asp ) 福岡県福岡市西区 姪浜駅南1丁目9番20号 姪浜電気ビル10階 定員 30名 名称 Rails初心者講習会 日時 7月21日 土曜日 12 30 ~ 18 30 会費 1人 3000円 #alpslab_route 準備 第二回Rails初心者講習会/準備するものを参照ください。 内容: Rubyとは Railsとは Rubyの文法解説 Railsハンズオン (本に基づいて練習) Railsのビジネスにおける実践・注意点・工夫など 参加申し込み 参加申し込みは、下記ウェブサイトから行ってください。 http //www.npo-aip.or.jp/index.asp
https://w.atwiki.jp/gonjoukk/pages/9.html
Ruby on Rails ドットインストールでの学習メモ ※MVCアーキテクチャ Model データ View 画面 Controller ModelとViewをとりもつもの 仮想マシンにログインし、ホームディレクトリで次を行う。 railsで、新規にアプリケーションの環境を作る 必要なディレクトリとファイルが作られ、必要なライブラリがインストールされる $ rails new myapp myappは、アプリケーション名(任意に設定する) myapp というディレクトリが作られ、その配下にいろんなファイルが作られる run bundle install と表示があれば、必要なライブラリがインストールされている 作成された アプリケーション名のディレクトリに移動 $ cd myapp railsサーバーを立ち上げる $ rails server (略して、 $ rails s でもいい) 環境によっては、次のエラーになる場合がある Could not find a JavaScript runtime その場合、vi Gemfile で以下の箇所に編集する # gem therubyracer , platforms ruby → gem therubyracer , platforms ruby コメントを外す そして、再度bundleインストールを行う $ bundle install 改めて、railsサーバーを立ち上げる $ rails s 以下の例では、WEBrick 1.3.1 というwebサーバが、port=3000 で立ち上がった [2014-08-15 09 40 24] INFO WEBrick 1.3.1 [2014-08-15 09 40 24] INFO ruby 2.1.2 (2014-05-08) [x86_64-linux] [2014-08-15 09 40 24] INFO WEBrick HTTPServer#start pid=3894 port=3000 webブラウザからサーバが立ち上がっていることを確認する URL= hostip(または hostname) 3000 例:192.168.33.56 3000 ◎ 作成方法1 scaffold を使って、railsアプリケーションを作ってみる $ rails generate scaffold User name string score integer $ rake db migrate railsサーバーを立ち上げる $ rails s ◎ 作成方法2 scaffold を使わず、railsアプリケーションを作ってみる $ rails new taskapp --skip-bundle $ cd taskapp
https://w.atwiki.jp/rubyocho/pages/16.html
Railsコマンド集 rails rails Usage /usr/bin/rails /path/to/your/app [options] Options -r, --ruby=path Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path). Default /usr/bin/ruby -d, --database=name Preconfigure for selected database (options mysql/oracle/postgresql/sqlite2/sqlite3). Default mysql -f, --freeze Freeze Rails in vendor/rails from the gems generating the skeleton Default false Rails Info -v, --version Show the Rails version number and quit. -h, --help Show this help message and quit. General Options -p, --pretend Run but do not make any changes. --force Overwrite files that already exist. -s, --skip Skip files that already exist. -q, --quiet Suppress normal output. -t, --backtrace Debugging show backtrace on errors. -c, --svn Modify files with subversion. (Note svn must be in path)
https://w.atwiki.jp/rubyist-kyushu/pages/11.html
Ruby on Rails講習会のご案内 Rubyユーザーグループ「Rubyist 九州」では、話題のWebフレームワーク Ruby on Railsの初心者講習会を開催することになりました。 Ruby on Railsは、強力なプログラミング言語Rubyを利用して、効率的にWebアプリケーションの開発を行うフレームワークです。2005年より爆発的な人気を博しているのは、皆様もご存知かと思います。 さて、今回のRuby on Rails講習会は、私たち「Rubyist 九州」が初めて行う初心者向けの講習会となります。九州ではRailsを学ぶ唯一の貴重な機会です。またユーザーグループによる開催ですので、参加費用も極めてお得になっています。 この素晴らしい機会に、御社人材のスキルアップを図りませんか? またRubyやRailsに興味のある方は、ぜひ個人としてご参加ください! 講習会の初回となりますので、不手際等もあるかと思いますが、どうぞご容赦ください。 開催概要 会場: アクロス 602号室 (定員 24名) 名称: Rails初心者講習会 日時: 6月2日 土曜日 13 00 ~ 18 00 会費: 1人 2500円 参加条件:ノートPC持参のこと (場合によっては1~2名分、用意可能) ウェブプログラミングを書いたことがある方が対象です 書籍 (RailsによるアジャイルWebアプリケーション開発) 持参のこと あらかじめ指定するプログラムをダウンロードしてきてください 第一回Rails初心者講習会/準備するもの 内容 Rubyとは Railsとは Rails ハンズオン (本に基づいて練習) Railsのビジネスにおける実践・注意点・工夫など 懇親会もあります 満員に付き応募締め切りました。ありがとうございました。
https://w.atwiki.jp/k_rororo/pages/20.html
Rails関連 ※rails version 3.2.1 db migrateをやりなおしたい場合 1つだけ戻す場合 $ rake db migrate redo rake タスクでのデータベース作成 $ rake db create RAILS_ENV=環境
https://w.atwiki.jp/programming_note/pages/14.html
Rails3 での deployment * rvm install 1.9.2 * rvm --default use 1.9.2 * gem install rails * gem install passenger * passenger-install-apache2-module
https://w.atwiki.jp/rubyocho/pages/14.html
Rails動作確認 テスト・スクリプトの起動 データベース接続 SQLiteの確認 itemモデルを生成 vi config/database.yml SQLite3のデータベースを作る。テーブルを作る itemモデル サービス起動 ブラウザから閲覧 http //localhost 3000/items/ サービス停止 テスト・スクリプトの起動 ユーザのホーム・ディレクトリから rails testapp cd testapp サービス起動 $ ruby script/server = Booting WEBrick... = Rails application started on http //0.0.0.0 3000 = Ctrl-C to shutdown server; call with --help for options [2007-05-06 14 00 12] INFO WEBrick 1.3.1 [2007-05-06 14 00 12] INFO ruby 1.8.5 (2006-08-25) [i386-linux] [2007-05-06 14 00 12] INFO WEBrick HTTPServer#start pid=2344 port=3000 ブラウザから閲覧 http //localhost 3000/ サービス停止 CTL+C [2007-05-06 14 14 13] INFO going to shutdown ... [2007-05-06 14 14 13] INFO WEBrick HTTPServer#start done. データベース接続 SQLiteの確認 itemモデルを生成 ruby script/generate model item exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/item.rb create test/unit/item_test.rb create test/fixtures/items.yml create db/migrate create db/migrate/001_create_items.rb vi config/database.yml development adapter sqlite3 database dev.db SQLite3のデータベースを作る。テーブルを作る $ sqlite3 dev.db SQLite version 3.3.6 Enter ".help" for instructions sqlite CREATE TABLE items (id INTEGER PRIMARY KEY, name TEXT); sqlite .quit itemモデル $ ruby script/generate scaffold item exists app/controllers/ exists app/helpers/ create app/views/items exists app/views/layouts/ exists test/functional/ dependency model exists app/models/ exists test/unit/ exists test/fixtures/ identical app/models/item.rb identical test/unit/item_test.rb identical test/fixtures/items.yml create app/views/items/_form.rhtml create app/views/items/list.rhtml create app/views/items/show.rhtml create app/views/items/new.rhtml create app/views/items/edit.rhtml create app/controllers/items_controller.rb create test/functional/items_controller_test.rb create app/helpers/items_helper.rb create app/views/layouts/items.rhtml create public/stylesheets/scaffold.css サービス起動 $ ruby script/server = Booting WEBrick... = Rails application started on http //0.0.0.0 3000 = Ctrl-C to shutdown server; call with --help for options [2007-05-06 15 15 03] INFO WEBrick 1.3.1 [2007-05-06 15 15 03] INFO ruby 1.8.5 (2006-08-25) [i386-linux] [2007-05-06 15 15 03] INFO WEBrick HTTPServer#start pid=3416 port=3000 ブラウザから閲覧 http //localhost 3000/items/ データ一覧から新規作成 データ入力 入力ができて、データ一覧 サービス停止 CTL+C [2007-05-06 14 14 13] INFO going to shutdown ... [2007-05-06 14 14 13] INFO WEBrick HTTPServer#start done.
https://w.atwiki.jp/kiminori_hirose/pages/16.html
Rails 1.2.3 のメモ 作成手順 プロジェクトの作成 projectプロジェクトを作成する。 $ rails project データベースの設定 config/database.ymlをMySQL用に編集する。(testとproductionもdevelopmentと同様に変更しておく。) development adapter mysql database project_development username {MySQLのユーザ名} password {パスワード} socket /var/lib/mysql/mysql.sock #ソケットのとき host localhost #TCP/IPのときのMySQLのホスト名 port 3306 #TCP/IPのときのMySQLのポート番号。指定してないときは、3306になる encoding utf8 #文字化け防止のためデータベースの文字コードを設定する。 文字コード(UTF-8)の指定 app/controllers/application.brにHTTPレスポンスで返すContent-Typeを追加する。 class ApplicationController ActionController Base after_filter set_charset protected def set_charset headers["Content-Type"] = text/html; charset=UTF-8 end end config/environment.rbにRailsの内部文字コードを追加する。 $KCODE = UTF8 Tips Railsの規約にあわない名前を持つテーブルのためにset_table_name を使う config/environment.rbファイルを編集 ActiveRecord Base.pluralize_table_names = false app/controllers/entity.rbを編集 class Entity ActiveRecord Base set_table_name "entity" end 主キーがidではないテーブルのためにset_primary_keyを使う app/controllers/entity.rbを編集 class Entity ActiveRecord Base set_primary_key "entity_id" end ActiveRecordで外部キーを指定する class Person ActiveRecord Base belongs_to company validates_associated campany end 独自の単数形と複数形を定義する config/environment.rbを編集 Inflector.inflections do |inflect| inflect.irregular leaf , leaves end セッションの有効期限を設定する プロジェクト全体で設定するには、config/environment.rbを編集 ActionController Base.session_options[ session_expires] = 15.minutes.from_now 特定のコントローラで設定するには、各コントローラを編集 class PersonController Application session session_expires = 10.minutes.from_now end HTMLエスケープとURIエンコード HTMLエスケープ a href=" %=h http //localhost/q=東京 -% " LINK /a URIエンコード a href=" %=u http //localhost/q=東京 -% " LINK /a
https://w.atwiki.jp/ntaka206/pages/17.html
RubyとRailsインストール@Win Rubyインストール RubyForge One-Click Ruby Installer Project Info http //rubyforge.org/projects/rubyinstaller/ Railsインストール コマンドプロンプトで gem install rails --include-dependencies 下記参照 RubyGemsによるRailsインストール - Railsのインストール - Railsインストール http //www.rubylife.jp/railsinstall/rails/index1.html NetBeans6.5で怒られる Missing the Rails 2.1.0 gem. Please `gem install -v=2.1.0 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed. gem install -v=2.1.0 rails MYSQL5.1 install GUI for 5.0 install no such file to load -- sqlite3 WEBを開くとエラーになる http //localhost 3000/main/index no such file to load -- sqlite3 対処 gem install sqlite3-ruby D \ gem install sqlite3-ruby Select which gem to install for your platform (i386-mswin32) 1. sqlite3-ruby 1.2.2 (mswin32) 2. sqlite3-ruby 1.2.2 (ruby) 3. sqlite3-ruby 1.2.1 (mswin32) 4. sqlite3-ruby 1.2.1 (ruby) 5. Skip this gem 6. Cancel installation 1 Successfully installed sqlite3-ruby-1.2.2-mswin32 Installing ri documentation for sqlite3-ruby-1.2.2-mswin32... Installing RDoc documentation for sqlite3-ruby-1.2.2-mswin32... まだエラー出る unknown error This error occurred while loading the following files sqlite3/driver/dl/driver sqlite3/driver/dl/api
https://w.atwiki.jp/ohden/pages/285.html
Ruby on Rails Ubuntu 10.04 Ruby 1.8.7 RubyGems 1.3.7 install install Rails5 install(2019-02-03) Rails7 install(2022-07-26) test run ~tips~ command備忘録 herokuでyarnを使う方法 Ruby/Rails/tips/ RAILS_ENV ほとんどのlinuxでは、実行commandの前に『【環境変数名】=【設定値】』と記載することで、そのcommandでのみ有効な環境変数を設定できる。 RAILS_ENV=development bin/rails db migrate RAILS_ENV=production bin/rails db migrate RAILS_ENV=test bin/rails db migrate port 3000を通す CentOS 7.3 $ sudo firewall-cmd --permanent --add-port=3000/tcp success 『--permanent』は設定を恒久的に行いたい場合に設定。 設定をreload。 $ sudo firewall-cmd --reload success 更新日: 2022年09月23日 (金) 23時04分10秒 has_many hoges def hoges hogehoge end のように関連名と同じmethodを定義すると、基本的にmethodの方が使われる。 が、他の関連のthroughからは、関連のhogesの方が参照される。らしい... -- (s1n) 2018-09-13 16 31 43 ActiveRecord絡みのメモ * scope * unscoped * default_scope * unscope(order name) -- (s1n) 2018-09-13 17 01 48 FactoryGirlで予約語と設定項目名がかぶる場合... add_attribute( factory){ "室蘭工場" } -- (s1n) 2018-09-13 17 35 55 apply_join_dependency eager_loadをjoins扱いしてくれる? -- (s1n) 2018-09-13 18 19 27 postgres+rspecが遅い... test環境やlocal環境で完結する話なら、`/etc/postgresql/10/main/postgresql.conf`の`fsync = off`としてしまうのも手。 システムコールfsyncはメモリ上とディスク上のfileを同期させる処理。なので、停電などでメモリ上にしかないデータが消えても大丈夫なlocal環境やtest環境ならoffってしまって性能重視にしてしまえと。 当然、本番環境で設定したらやばいことが起こりそうなので注意。 -- (s1n) 2018-09-20 11 43 48 https //blog.freedom-man.com/activerecord-join-order-limit/ join, order, limitで件数がおかしくなる問題 -- (s1n) 2018-09-25 09 56 24 http //api.rubyonrails.org/classes/ActiveRecord/Reflection/ClassMethods.html 関連の情報を取る方法。 Model.reflect_on_all_associations 関連名だけ欲しかったら Model.reflect_on_all_associations.map( name) で一通り取れる。 belongs_to関連だけ取得したかったら Model.reflect_on_all_associations( belongs_to) has_many関連だけ取得したかったら Model.reflect_on_all_associations( has_many) なんて条件で絞り込んだりもできる。 関連名を指定してやると対象の情報を取れる Model.reflect_on_association( column_name) なんてのもある。指定した関連が無かったらnilが帰ってくる。 他にもhashがもらえる Model.reflections なんてのもある。 -- (s1n) 2018-09-27 14 30 14 DBにmysqlを選んだ場合、defaultで『collate utf8_unicode_ci』が有効なSQLが吐かれる。 なので、『%ほげ%』でlike検索を行った場合『%ホゲ%』『%ホゲ%』も検索対象になってしまうらしい。 -- (s1n) 2018-10-24 11 21 27 railsのように意味のないuniqな数字をprimary keyとして割り振ったkeyをサロゲートキーと呼ぶ。 -- (s1n) 2019-11-01 09 55 03 railsでPostgreSQLを使いたい場合、pgを入れる必要がある。 pgを入れるには、予めPostgreSQLをinstall済でないとダメ。 $ sudo apt install postgresql -- (s1n) 2020-02-06 12 40 13 名前 コメント すべてのコメントを見る